<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Methods Option 方法选项</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>Methods Option 方法选项</h1>
    <hr>
    <div id="app">
        {{num}}
        <!-- <button @click="add(3,$event)">++</button> -->
        <!-- native 给组件绑定构造器里的原生事件 -->
        <p><btn @click.native="add(4)"></btn></p>

    </div>
</body>
<script>
    var btn = {
        template:`<button>组件Add</button>`
    }
    var app = new Vue({
        el:"#app",
        data:{ 
           num:1
        },
        components:{
            "btn":btn
        },
        methods: {
            add(Num){
                // this.num++
                if(Num!=""){
                    this.num+=Num
                    // console.log(event)
                }else{
                    this.num++
                }
            }
        }
    })
</script>
</html>